import xcorr
reload(xcorr)

if 0:
    lbgs, qsos_hires, qsos_aaom, spec_hires, spec_aaom = xcorr.read_data()

if 0:
    ###########################################################
    # Transmissivity calculation
    ###########################################################

#     meanfls, idgals = xcorr.run_trans_and_plot(
#         qsos_hires, spec_hires, lbgs,
#         title='No scaling', zscale=False,
#         singleplot=True, per_spec_plots=False)

    meanfls, idgals = xcorr.run_trans_and_plot(
        qsos_hires, spec_hires, lbgs,
        title='No scaling', zscale=False,
        singleplot=True, per_spec_plots=True)

    # Now plot the lot
    #xcorr.do_boxplot(meanfls,'6 HIRES QSOs', 'all_meanfl_hires_noscale.pdf')
    xcorr.do_errplot(meanfls,'6 HIRES QSOs no scaling',
                     'all_meanfl_hires_noscale_std.pdf')

    meanfls, idgals = xcorr.run_trans_and_plot(
        qsos_hires, spec_hires, lbgs,
        title='Scale flux by evolving expected mean', zscale=True,
        singleplot=True, per_spec_plots=False)

    #xcorr.do_boxplot(meanfls,'6 HIRES QSOs',
    #                 'all_meanfl_hires_scalefz.pdf')
    xcorr.do_errplot(meanfls,'6 HIRES QSOs scale by f(z)',
                     'all_meanfl_hires_scalefz_std.pdf')

    meanfls, idgals = xcorr.run_trans_and_plot(
        qsos_hires, spec_hires, lbgs,
        title='Scale flux by measured mean', zscale='mean',
        singleplot=True, per_spec_plots=False)

    #xcorr.do_boxplot(meanfls, '6 HIRES QSOs',
    #                 'all_meanfl_hires_scalemean.pdf')
    xcorr.do_errplot(meanfls, '6 HIRES QSOs scale by mean',
                     'all_meanfl_hires_scalemean_std.pdf')

    idgals_hires = idgals
    xcorr.do_ngalplot(idgals_hires, '6 HIRES', 'ngal_hires.pdf', show=True)

if 1:
    meanfls, idgals = xcorr.run_trans_and_plot(
        qsos_aaom, spec_aaom, lbgs,
        title='No scaling', zscale=False, singleplot=True,
        info='aaom', per_spec_plots=True)

    #xcorr.do_boxplot(meanfls,'41 AA$\Omega$ QSOs',
    #                 'all_meanfl_aaom_noscale.pdf')
    xcorr.do_errplot(meanfls, '41 AA$\Omega$ QSOs no scaling',
                     'all_meanfl_aaom_noscale_std.pdf')

    meanfls, idgals = xcorr.run_trans_and_plot(
        qsos_aaom, spec_aaom, lbgs,
        title='Scale flux by evolving expected mean', zscale=True,
        singleplot=True, info='aaom', per_spec_plots=False)

    #xcorr.do_boxplot(meanfls,'41 AA$\Omega$ QSOs',
    #                 'all_meanfl_aaom_scalefz.pdf')
    xcorr.do_errplot(meanfls, '41 AA$\Omega$ QSOs scale by f(z)',
                     'all_meanfl_aaom_scalefz_std.pdf')

    meanfls, idgals = xcorr.run_trans_and_plot(
        qsos_aaom, spec_aaom, lbgs,
        title='Scale flux by measured mean', zscale='mean',
        singleplot=True, info='aaom', per_spec_plots=False)

    #xcorr.do_boxplot(meanfls,'41 AA$\Omega$ QSOs',
    #                 'all_meanfl_aaom_scalemean.pdf')
    xcorr.do_errplot(meanfls, '41 AA$\Omega$ QSOs scale by mean',
                     'all_meanfl_aaom_scalemean_std.pdf')

    idgals_aaom = idgals

    # plo of ngal for aaom and hires
    xcorr.do_ngalplot(idgals_aaom, 'AAOm', 'ngal_aaom.pdf', show=True)
    
